<template>
  <div class="main-content">
    <div class="mine-bg">
      <div class="top-bg"></div>
      <div class="bg-cover"> 
        <img src="@/assets/img/min-img-01.png" alt="">
      </div>
    </div>
    <div class="mine-main">
      <div class="mine-header flex-box">
        <div class="left flex-box" @click="toLogIn">
          <div class="head-box flex-box">
            <svg class="icon" aria-hidden="true">
              <use xlink:href="#icon-gb-xiugaitouxiang"></use>
            </svg>
            <img v-if="logState" src="@/assets/img/gb-pro-01.jpg">
          </div>
          <p>{{logState?'张大大':'登录/注册'}}</p>
        </div>
        <div class="right" v-if="logState">
          <p @click="toUserSet">
            <span><svg class="icon" aria-hidden="true">
              <use xlink:href="#icon-gb-24"></use>
            </svg></span><br>
            <i>设置</i>
          </p>
        </div>
      </div>
      <div class="mine-icons">
        <ul class="flex-box">
          <li @click="toMineData()"><svg class="icon" aria-hidden="true">
                <use xlink:href="#icon-gb-daifukuan"></use>
              </svg>
              <p>待付款</p>
              <h6 v-if="logState">5</h6>
          </li>
          <li @click="toMineData()"><svg class="icon" aria-hidden="true">
                <use xlink:href="#icon-gb-daishouhuo"></use>
              </svg>
              <p>待收货</p>
              <h6 v-if="logState">85</h6>
          </li>
          <li @click="toMineData()"><svg class="icon" aria-hidden="true">
                <use xlink:href="#icon-gb-daipingjia"></use>
              </svg>
              <p>待评价</p>
          </li>
          <li @click="toMineData()"><svg class="icon" aria-hidden="true">
                <use xlink:href="#icon-gb-tuihuanshouhou"></use>
              </svg>
              <p>退换/售后</p>
          </li>
          <li @click="toMineData()"><svg class="icon" aria-hidden="true">
                <use xlink:href="#icon-gb-quanbudingdan"></use>
              </svg>
              <p>全部订单</p>
          </li>
        </ul>
      </div>
      <h2 class="part-title">我的服务</h2>
      <div class="fuwu-box">
        <ul class="flex-box">
          <li @click="toMineData('http://my.genebook.com.cn/wallet/coupon')">
            <img src="@/assets/img/mine-icon-01.png">
            <p>优惠券</p>
          </li>
          <li @click="toMineData()">
            <img src="@/assets/img/mine-icon-02.png">
            <p>积分</p>
          </li>
          <li @click="toMineData()">
            <img src="@/assets/img/mine-icon-03.png">
            <p>我的检测</p>
          </li>
          <li @click="toMineData()">
            <img src="@/assets/img/mine-icon-04.png">
            <p>华大币</p>
          </li>
          <li @click="toMineData()">
            <img src="@/assets/img/mine-icon-05.png">
            <p>充值</p>
          </li>
        </ul>
      </div>
      <h2 class="part-title">推荐商品</h2>
      <div class="tuijian-box">
        <ul>
          <li>
            <div class="img-box">
              <img src="@/assets/img/gb-pro-02.jpg">
            </div>
            <div class="des-box">
              <h4>益畅|益生菌压片糖果-120片</h4>
              <h5>￥168.0</h5>
            </div>
          </li>
          <li>
            <div class="img-box">
              <img src="@/assets/img/gb-pro-02.jpg">
            </div>
            <div class="des-box">
              <h4>益畅|益生菌压片糖果-120片</h4>
              <h5>￥168.0</h5>
            </div>
          </li>
          <li>
            <div class="img-box">
              <img src="@/assets/img/gb-pro-02.jpg">
            </div>
            <div class="des-box">
              <h4>益畅|益生菌压片糖果-120片</h4>
              <h5>￥168.0</h5>
            </div>
          </li>
          <li>
            <div class="img-box">
              <img src="@/assets/img/gb-pro-02.jpg">
            </div>
            <div class="des-box">
              <h4>益畅|益生菌压片糖果-120片</h4>
              <h5>￥168.0</h5>
            </div>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
// @ is an alias to /src
import { mapActions, mapState } from 'vuex'
export default {
  name: 'mallMine',
  data() {
    return {
      lists: ''
    }
  },
  components: {},
  computed: {
    ...mapState({
      logState: state => state.global.isLogIn,
      userData: state => state.global.userData
    })
  },
  methods: {
    ...mapActions({
      setUserSate: 'global/set_user_state',
      getUserData: 'global/get_user_data'
    }),
    toMineData() {
      if (!this.logState) {
        this.$router.push('/login')
      } else {
        window.location.href = 'http://my.genebook.com.cn/wallet/coupon/1'
        // this.$router.push('/iframe?link=' + link)
      }
    },
    toLogIn() {
      if (this.logState) {
        return
      } else {
        this.$router.push('/login')
      }
      // this.setUserSate(true)
    },
    toUserSet() {
      this.$router.push('/userset')
    },
    toIframe(link) {
      this.$router.push('/iframe?link=' + link)
    }
  },
  mounted() {
    // console.log(this.logState)
  }
}
</script>
<style scoped lang="scss">
.main-content {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  .mine-bg {
    width: 100%;
    height: 165px;
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
    .top-bg {
      width: 1500px;
      height: 1500px;
      position: absolute;
      bottom: 0;
      left: 50%;
      margin-left: -750px;
      border-radius: 1500px;
      background-image: linear-gradient(to right, #1d7cc6 40%, #1a96cc 60%);
    }
    .bg-cover {
      width: 165px;
      top: 0;
      left: 0;
      position: absolute;
      z-index: 2;
      img {
        width: 100%;
      }
    }
  }
  .mine-main {
    width: 100%;
    position: relative;
    z-index: 9;
    padding-top: 30px;
    .mine-header {
      justify-content: space-between;
      -webkit-justify-content: space-between;
      padding: 0 20px;
      width: 100%;
      box-sizing: border-box;
      .left {
        .head-box {
          width: 54px;
          height: 54px;
          border-radius: 54px;
          background: rgba($color: #4bc0eb, $alpha: 0.6);
          border: 1px solid #4bc0eb;
          position: relative;
          svg {
            font-size: 24px;
            color: #fff;
          }
          img {
            width: 100%;
            height: 100%;
            border-radius: 54px;
            overflow: hidden;
            position: absolute;
            top: 0;
            left: 0;
          }
        }
        p {
          font-size: 16px;
          color: #fff;
          margin-left: 10px;
          letter-spacing: 1px;
        }
      }
      .right {
        color: #fff;
        font-size: 12px;
        letter-spacing: 1px;
        svg {
          font-size: 24px;
          margin-bottom: 8px;
        }
      }
    }
    .mine-icons {
      width: 100%;
      padding: 0 20px;
      box-sizing: border-box;
      margin-top: 20px;
      ul {
        width: 100%;
        height: 90px;
        border-radius: 8px;
        background: #fff;
        justify-content: space-around;
        -webkit-justify-content: space-around;
        li {
          width: 20%;
          position: relative;
          svg {
            font-size: 28px;
          }
          p {
            font-size: 12px;
            line-height: 18px;
            margin-top: 6px;
            color: #000;
          }
          h6 {
            font-size: 10px;
            position: absolute;
            top: -2px;
            left: 50%;
            margin-left: 4px;
            line-height: 12px;
            border: 1px solid #f00;
            background: #fff;
            color: #f00;
            padding: 0 3px;
            border-radius: 10px;
          }
        }
      }
    }
    .fuwu-box {
      width: 100%;
      padding: 0 20px;
      box-sizing: border-box;
      ul {
        width: 100%;
        height: 90px;
        padding: 8px 0;
        border-radius: 8px;
        background: #fff;
        justify-content: space-around;
        -webkit-justify-content: space-around;
        li {
          width: 20%;
        }
        img {
          width: 30px;
        }
        p {
          font-size: 12px;
          line-height: 18px;
          margin-top: 6px;
          color: #000;
        }
      }
    }
    .tuijian-box {
      width: 100%;
      padding: 0 20px;
      overflow: hidden;
      box-sizing: border-box;
      ul {
        width: 100%;
        padding: 12px 7px;
        box-sizing: border-box;
        overflow: hidden;
        background: #fff;
        border-radius: 8px;
        li {
          width: 50%;
          float: left;
          padding: 8px;
          text-align: left;
          overflow: hidden;
          box-sizing: border-box;
          margin-bottom: 2px;
          .img-box {
            width: 100%;
            padding-bottom: 100%;
            position: relative;
            border-radius: 6px;
            overflow: hidden;
            img {
              width: 100%;
              height: 100%;
              position: absolute;
              top: 0;
              left: 0;
            }
          }
          .des-box {
            font-size: 12px;
            line-height: 17px;
            h4 {
              color: #000000;
              margin-top: 10px;
              overflow: hidden;
              text-overflow: ellipsis;
              white-space: nowrap;
            }
            h5 {
              color: #fc4549;
              display: inline-block;
              margin-top: 5px;
            }
          }
        }
      }
    }
    h2 {
      &.part-title {
        font-size: 15px;
        font-weight: bold;
        color: #000;
        padding: 15px 20px;
        text-align: left;
      }
    }
  }
}
</style>
